package stark.app.function.tbs;

import android.content.Intent;

import com.stark.doc.selector.DefDocSelActivity;

import androidx.annotation.Nullable;
import stark.app.R;
import stark.app.databinding.ActivityTbsDemoBinding;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.constant.Extra;
import stark.common.basic.media.MediaInfo;

/**
 * Author：daizhongbin on 2022/7/15
 * Email：1027154338@qq.com
 * Desc:
 */
public class TbsDemoActivity extends BaseNoModelActivity<ActivityTbsDemoBinding> {

    @Override
    protected int onCreate() {
        return R.layout.activity_tbs_demo;
    }

    @Override
    protected void initView() {
        mDataBinding.btnTbsReader.setOnClickListener(v -> {
            selDoc();
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) return;
        if (requestCode == REQ_SEL_FILE) {
            if (data == null) return;
            MediaInfo mediaInfo = (MediaInfo) data.getSerializableExtra(Extra.DATA);
            TbsReaderActivity.start(this, mediaInfo.getPath());
        }
    }

    private static final int REQ_SEL_FILE = 1;

    private void selDoc() {
        DefDocSelActivity.selFile(this, REQ_SEL_FILE);
    }

}
